package bancosys.tec.security.impl.services.incluir;

import jmine.tec.di.annotation.Injected;
import jmine.tec.services.annotations.Input;
import jmine.tec.services.annotations.ServiceImplementor;
import jmine.tec.services.api.ActionsEnum;
import jmine.tec.services.api.RawInput;
import jmine.tec.services.api.export.ReferenceMap;
import jmine.tec.services.export.impl.ExportUtils;
import jmine.tec.services.io.ServiceBean;
import bancosys.tec.security.impl.domain.TaskCredential;

/**
 * Serviço para incluir Credenciais de Task
 * 
 * @author lundberg
 */
@ServiceImplementor(action = ActionsEnum.INCLUIR)
public class TaskCredentialService extends AbstractCredentialService<TaskCredential> {

    public static final String TASK = "Tarefa";

    public static final String DESCRIPTION = "Descrição";

    private RawInput rawInput;

    private String description;

    /**
     * {@inheritDoc}
     */
    @Override
    protected void fillCredential(TaskCredential credential) {
        credential.setTaskName(this.rawInput.getRaw(TASK));
        credential.setDescription(this.description);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void fillServiceBean(ServiceBean bean, ReferenceMap referenceMap, TaskCredential entity) {
        super.fillServiceBean(bean, referenceMap, entity);
        ExportUtils.put(bean, TASK, entity.getTaskName());
        ExportUtils.put(bean, DESCRIPTION, entity.getDescription());
    }

    /**
     * @param rawInput the rawInput to set
     */
    @Injected
    public void setRawInput(RawInput rawInput) {
        this.rawInput = rawInput;
    }

    /**
     * @param task to set
     */
    @Input(fieldName = TASK)
    public void setTask(String task) {
    }

    /**
     * @param description Descrição da credencial.
     */
    @Input(fieldName = DESCRIPTION, required = false)
    public void setDescription(String description) {
        this.description = description;
    }
}
